package com.xgzit.xgzmall.order.config;

import com.xgzit.xgzmall.order.interceptor.LoginUserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * web配置类
 * 1、必须实现 WebMvcConfigurer
 * 2、可以添加拦截器
 * @Author xgz
 * @Date 2021-06-26 19:11
 */

@Configuration
public class OrderWebConfiguration implements WebMvcConfigurer {

    @Autowired
    LoginUserInterceptor loginUserInterceptor;

    /** 添加拦截器 **/
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加我们定义的拦截器， /** 表示拦截所有请求
        registry.addInterceptor(loginUserInterceptor).addPathPatterns("/**");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
